package com.leyou.order.config;

import com.leyou.auth.utils.RsaUtils;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import javax.annotation.PostConstruct;
import java.security.PublicKey;

/**
 * @author huangxin
 * @date 2019/5/11-19:46
 */
@ConfigurationProperties(prefix = "ly.jwt")
@Data
public class JwtProperties {
    private String pubKeyPath;
    private String cookieName;

    private PublicKey publicKey;//公钥

    //类一旦初始化,就应该读取公钥
    @PostConstruct
    public void init() throws Exception {
        //读取公钥
        this.publicKey = RsaUtils.getPublicKey(pubKeyPath);
    }
}
